﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace Snai.CMS.Manage.Migrations
{
    public partial class Initial : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "admins",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("MySQL:AutoIncrement", true),
                    user_name = table.Column<string>(nullable: true),
                    password = table.Column<string>(nullable: true),
                    state = table.Column<byte>(nullable: false),
                    role_id = table.Column<int>(nullable: false),
                    create_time = table.Column<int>(nullable: false),
                    update_time = table.Column<int>(nullable: false),
                    last_logon_time = table.Column<int>(nullable: false),
                    last_logon_ip = table.Column<string>(nullable: true),
                    error_logon_time = table.Column<int>(nullable: false),
                    error_logon_count = table.Column<int>(nullable: false),
                    lock_time = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_admins", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "modules",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("MySQL:AutoIncrement", true),
                    parent_id = table.Column<int>(nullable: false),
                    title = table.Column<string>(nullable: true),
                    controller = table.Column<string>(nullable: true),
                    action = table.Column<string>(nullable: true),
                    sort = table.Column<int>(nullable: false),
                    state = table.Column<byte>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_modules", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "role_right",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("MySQL:AutoIncrement", true),
                    role_id = table.Column<int>(nullable: false),
                    module_id = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_role_right", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "roles",
                columns: table => new
                {
                    id = table.Column<int>(nullable: false)
                        .Annotation("MySQL:AutoIncrement", true),
                    title = table.Column<string>(nullable: true),
                    state = table.Column<byte>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_roles", x => x.id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "admins");

            migrationBuilder.DropTable(
                name: "modules");

            migrationBuilder.DropTable(
                name: "role_right");

            migrationBuilder.DropTable(
                name: "roles");
        }
    }
}
